package io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
/**
 * 当我们提高每次读写的数据量减少实际读写次数就可以提高读写效率
 */
public class CopyDemo2 {
    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("qqqq.jpg");
        FileOutputStream fos = new FileOutputStream("dddd.jpg");

        byte[] data = new byte[1024];
        int d;
        long start = System.currentTimeMillis();
        while ((d = fis.read(data)) != -1) {
            fos.write(data, 0, d);

        }
        System.out.println("复制完毕");
        long end = System.currentTimeMillis();
        long time = end - start;
        System.out.println("用时" + time + "毫秒");
        fis.close();
        fos.close();
    }
}
